
proc assert {condition msg} {
	if {![uplevel expr $condition]} {return -code error [uplevel list $msg]}
}

proc inform {msg} {
	puts stderr $msg
}

proc capitalize {word} {
	return [string toupper [string index $word 0]][string range $word 1 end]
}

proc absolve {fileSpec {workDir ""}} {
	global eWorkDir
	
	if {![string length $workDir]} {set workDir $eWorkDir}
	regsub -all "\\\\" $fileSpec "/" fileSpec
	if {[regexp -nocase "^\[a-z\]+:" $fileSpec]} {return $fileSpec}
	if {[string compare [string index $fileSpec 0] "\/"] == 0} {
		if {![regexp -nocase "^\[a-z\]+:" $workDir drive]} {return $fileSpec}
		return $drive$fileSpec
	}
	return $workDir/$fileSpec
}

proc lapply {list op args} {
	set resultList {}
	foreach el $list {
		lappend resultList [uplevel 1 [list eval $op [list $el] $args]]
	}
	return $resultList
}

proc lprepend {listPtr args} {
	upvar $listPtr listVar
	set listVar [concat $args $listVar]
}

proc linit {list params defaults} {
	foreach paramPtr $params val [lrange $list 0 [expr [llength $params] - 1]] def [lrange $defaults 0 [expr [llength $params] - 1]] {
		upvar $paramPtr paramVar
		if {[string length $val]} {
			set paramVar $val
		} else {
			set paramVar $def
		}
	}
}